package com.gotloop.util;

import javax.jdo.JDOHelper;
import javax.jdo.PersistenceManagerFactory;

import org.springframework.stereotype.Component;

/**
 * Singleton used to initialize EntityManagerFactory only once.
 * @author jibhaine
 *
 */
@Component
public final class PMF {
	/**
	 * Factory used to create the EntityManager.
	 */
	private static PersistenceManagerFactory pmf;

	/**
	 * Private Constructor.
	 */
    private PMF() {
    	
    }
	/**
	 * Initialize the PersistanceManagerFactory only once.
	 * @return the PersistenceManagerFactory instance
	 */
    public PersistenceManagerFactory get() {
    	if (pmf == null) {
    		pmf = JDOHelper.getPersistenceManagerFactory("gotloop-unit");
    	}
    	return pmf;
    }
    
}